
MKDIR_P = mkdir -p
LN_S = ln -s

# LINK_MODE:
#   SHARED  - for .so
#   DYNAMIC - for .dylib (Darwin) or .dll (Windows, not yet..)
#   STATIC  - for .a
LINK_MODE = SHARED

# COMPILE_MODE:
#   DEBUG   - generate debugging information and verbose logging
#   RELEASE - without debugging information, logging, safety checks
COMPILE_MODE = DEBUG

BUILDDIR = $(PROJECTDIR)/build

OBJDIR = $(BUILDDIR)/$(SUBDIR)
LIBDIR = $(BUILDDIR)
BINDIR = $(BUILDDIR)

CC = clang
CFLAGS_DEBUG = -O3 -Wall -DDEBUG -g
CFLAGS_RELEASE = -O3 -Wall
CFLAGS = $(CFLAGS_$(COMPILE_MODE)) -I$(PROJECTDIR) -DSUBDIR=\"$(SUBDIR)\" #-DNO_LOG -DNO_ASSERT -DNO_PRECOND -DNO_ERROR
CFLAGS_OBJ_SHARED = $(CFLAGS) -c -fPIC
CFLAGS_OBJ_DYNAMIC = $(CFLAGS) -c -fPIC
CFLAGS_OBJ_STATIC = $(CFLAGS) -c
CFLAGS_OBJ = $(CFLAGS_OBJ_$(LINK_MODE))

LD = $(CC)
LDFLAGS_DEBUG = -O4 -g
LDFLAGS_RELEASE = -O4 -Wl,-S,-x
LDFLAGS = $(LDFLAGS_$(COMPILE_MODE)) -L$(LIBDIR)
LDFLAGS_LIB_SHARED = $(LDFLAGS) -shared
LDFLAGS_LIB_DYNAMIC = $(LDFLAGS) -dynamiclib -undefined suppress -flat_namespace
LDFLAGS_LIB = $(LDFLAGS_LIB_$(LINK_MODE))
LDFLAGS_BIN = $(LDFLAGS)

AR = ar
ARFLAGS_LIB = c

LIB_SUFFIX_SHARED = .so
LIB_SUFFIX_DYNAMIC = .dylib
LIB_SUFFIX_STATIC = .a
LIB_SUFFIX = $(LIB_SUFFIX_$(LINK_MODE))
BIN_SUFFIX =

COMPILE_OBJ = $(CC) $(CFLAGS_OBJ) -o $@ $<
LINK_LIB_SHARED = $(LD) $(LDFLAGS_LIB) -o $@ $^
LINK_LIB_DYNAMIC = $(LD) $(LDFLAGS_LIB) -o $@ $^
LINK_LIB_STATIC = $(AR) rs$(ARFLAGS_LIB) $@ $^
LINK_LIB = $(LINK_LIB_$(LINK_MODE))
LINK_BIN = $(CC) $(CFLAGS) $^ $(LDFLAGS_BIN) -o $@

DRIVERS=applemidi

